<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);

//define root path of application
define('BASEPATH', dirname(dirname(__FILE__)));

define('NOCACHE', (isset($_GET['nocache']) ? TRUE : FALSE));

require_once('./includes/config.inc.php');
require_once('./lib/include_dir.function.php');
//include all the helpers and functions
include_dir('./lib');

session_set_cookie_params(7 * 24 * 3600);
session_start();

$open_pages = array(
    'login.php',
    'register.php',
    'forgotpassword.php',
    'resetpassword.php',
);

$get = $_SERVER['REQUEST_URI'];
if(strpos($get, '?')) {
    $get = substr($get, 0, strpos($get, '?'));
}
if(!isset($_SESSION['user']) && !in_array(basename($get), $open_pages)) {
    header('Location: /login.php');
    exit();
}

$userMgr = new User();
$diffMgr = new Difficulty();
$colourMgr = new Colour();
$locationMgr = new Location();
$routeMgr = new Route();
$authorMgr = new Author();
$templateMgr = new Template();
$checkinMgr = new Checkin();
?>
